/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.upc.dew.controlventas.dao;

import java.util.ArrayList;
import java.util.List;
import pe.edu.upc.dew.controlventas.model.LineaCredito;

/**
 *
 * @author u814296
 */
public class LineaCreditoDao {

    List<LineaCredito> lineasCreditos = new ArrayList<LineaCredito>();

    public LineaCreditoDao(){

        LineaCredito lc1 = new LineaCredito();
        lc1.setId(1);
        lc1.setNombre("Normal");
        lc1.setRangoMin(100);
        lc1.setRangoMax(600);

        lineasCreditos.add(lc1);

        LineaCredito lc2 = new LineaCredito();
        lc2.setId(2);
        lc2.setNombre("Silver");
        lc2.setRangoMin(600);
        lc2.setRangoMax(2000);

        lineasCreditos.add(lc2);
        

        LineaCredito lc3 = new LineaCredito();
        lc3.setId(3);
        lc3.setNombre("Gold");
        lc3.setRangoMin(2000);
        lc3.setRangoMax(5000);

        lineasCreditos.add(lc3);
        
        
    }

    public LineaCredito buscarLineaCredito(double sueldo){

        for (int i = 0; i < lineasCreditos.size(); i++) {
            LineaCredito lineaCredito = lineasCreditos.get(i);
            if(lineaCredito.getRangoMin()<= sueldo && lineaCredito.getRangoMax()>=sueldo){
                return lineaCredito;
            }
        }

        return null;

    }


    /**
     * 
     * @param username
     * @return Usuario
     */
    public List<LineaCredito> getLineasCreditos() {
        return lineasCreditos;
    }


}
